-- shipments.lua

Shipments = {}
function AddShipment( ShipmentName, Entity, Model, Cost, Quantity, CostMulti, Occupations )
	local Shipment = { 
		ShipmentName = ShipmentName,
		Entity = Entity,
		Model = Model,
		Cost = Cost,
		Quantity = Quantity,
		CostMulti = CostMulti,
		Occupations = Occupations
	}
	table.insert(Shipments, Shipment)
end

-- ShipmentName - What the shipment will be named in the shipments menu
-- Model - The model of the entities as they come out the shipment
-- Entity - The actual entity
-- Cost - How much one costs
-- Quantity - Different quantities it's available in
-- CostMulti - Discounts on multiple quantities
-- Occupations - Which occupations can purchase this shipment

-- "models/Items/item_item_crate.mdl", 

AddShipment( "USP Match", "weapon_pistol", "models/weapons/w_pistol.mdl", 
	500, { 1, 5, 10, 20 }, { 1, 0.95, 0.9, 0.8 }, { OCCUPATION_ARMSDEALER } )
AddShipment( ".357 Magnum", "weapon_357", "models/weapons/w_357.mdl", 
	500, { 1, 5, 10, 20 }, { 1, 0.95, 0.9, 0.8 }, { OCCUPATION_ARMSDEALER } )
AddShipment( "Spas-12", "weapon_shotgun", "models/weapons/w_shotgun.mdl", 
	500, { 1, 5, 10, 20 }, { 1, 0.95, 0.9, 0.8 }, { OCCUPATION_ARMSDEALER } )
AddShipment( "MP7", "weapon_smg1", "models/weapons/w_smg1.mdl", 
	500, { 1, 5, 10, 20 }, { 1, 0.95, 0.9, 0.8 }, { OCCUPATION_ARMSDEALER } )
AddShipment( "IRifle", "weapon_ar2", "models/weapons/w_IRifle.mdl", 
	500, { 1, 5, 10, 20 }, { 1, 0.95, 0.9, 0.8 }, { OCCUPATION_ARMSDEALER } )

if not SERVER then return end



function BuyShipment(ply, cmd, args )
	local Shipment = Shipments[tonumber(args[1])]
	if not Shipment then return end
	
	local trace = {}
	trace.start = ply:EyePos()
	trace.endpos = trace.start + ply:GetAimVector() * 50
	trace.filter = ply
	local tr = util.TraceLine(trace)

	local ShipmentEnt = ents.Create("shipment")
	ShipmentEnt:Fill( Shipment.Entity, Shipment.Model, 10 )
	ShipmentEnt:SetPos(Vector(tr.HitPos.x, tr.HitPos.y, tr.HitPos.z))
	ShipmentEnt:Spawn()
end
concommand.Add("RP_BuyShipment", BuyShipment)